<template>
    <div class="apiForm">
        <el-row>
            <el-col :md="10" :offset="7">
                <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                    <el-form-item
                        label="名称"
                        prop="name"
                    >
                        <el-input v-model="ruleForm.name" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item
                        label="接口用户名"
                        prop="apiname"
                    >
                        <el-input v-model="ruleForm.apiname" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item
                        label="接口密码"
                        prop="apipassword"
                    >
                        <el-input  v-model="ruleForm.apipassword" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item
                        label="接口密钥"
                        prop="apissh"
                    >
                        <el-input  v-model="ruleForm.apissh" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item
                        label="备注"
                        prop="note"
                    >
                        <el-input  v-model="ruleForm.note" auto-complete="off"></el-input>
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="submitForm('ruleForm')">提交</el-button>
                        <el-button @click="resetForm('ruleForm')">取消</el-button>
                    </el-form-item>
                </el-form>
            </el-col>
        </el-row>
    </div>

</template>
<script>
    export default {
    data() {
      return {
        ruleForm: {
            name: '',
          apiname: '',
          apipasword: '',
          apissh: '',
          note: ''

        },
        rules: {
          name: [
            { required: true, message: '请输入接口名称', trigger: 'blur' }
          ],
          apiname: [
            {required: true, message: '请输入接口用户名', trigger: 'blur' }
          ],
          apipassword: [
            { required: true, message: '请输入接口密码', trigger: 'blur' }
          ],
          apissh: [
            { required: true, message: '请输入接口密钥', trigger: 'blur' }
          ]
        }
      };
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            alert('submit!');
          } else {
            console.log('error submit!!');
            return false;
          }
        });
      },
      resetForm(formName) {
        this.$refs[formName].resetFields();
        this.$router.push({
            path: '/carrier/' + this.$store.getters.carrier.carrierId +'/china_telecom_api_accounts'
        })
      }
    }
    }
</script>
<style lang="scss" scoped>
    .select {
        width: 100%;
    }
</style>

